<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UsuariosBD
 *
 * @author Rafael Ferreira
 */
class UsuariosBD extends UsuariosEO{
   
    public function UpdateSpecificUsuarios(){
        $pdo = parent::getBD();
        
        $sql = $pdo->prepare("UPDATE usuarios SET Nome='?',Sobrenome='?',Email='?',Usuario ='?',Senha ='?' WHERE cUsuario = '?'");
        
        $sql->bindValue(1, $this->getNome());
        $sql->bindValue(2, $this->getSobrenome());
        $sql->bindValue(3, $this->getEmail());
        $sql->bindValue(4, $this->getUsuario());
        $sql->bindValue(5, $this->getSenha());
        
        $sql->bindValue(6, $this->getcUsuario());
        $sql->execute();
        
        if($sql->rowCount() == 1):
            return true;
        else:
            return false;
        endif;
    }
    public function SelectSpecificUsuarios(){
        $pdo = parent::getBD();
        
        $sql = $pdo->prepare("SELECT * FROM usuarios WHERE cUsuario = ?");
        $sql->bindValue(1, $this->getcUsuario());
        $sql->execute();
        
        if($sql->rowCount() > 0):
            $dados = $sql->fetch(PDO::FETCH_OBJ);
            return $dados;
        else:
            return null;
        endif;
    }

    public function SelectAllUsuarios(){
        $pdo = parent::getBD();
        
        $sql = $pdo->prepare("SELECT * FROM usuarios");
        $sql->execute();
        
        if($sql->rowCount() > 0):
            $dados = $sql->fetchAll(PDO::FETCH_ASSOC);
            return $dados;
        else:
            return null;
        endif;
    }
    
}
